package com.baizhi.web_demo;

/**
 * String  replaceAll(String regex,String str)
 * 将当前字符串中满足正则表达式的部分进行替换
 */
public class RegMethod02 {
    public static void main(String[] args) {
        String str = "abc123def456hig789klm";

        //需求：将所有的数字替换成 #NUMBER

        String reg = "[0-9]+";
        String s = str.replaceAll(reg, "#NUMBER");
        System.out.println(s);


        //和谐用语
        String regex = "(wqnmlgb|sb|cnm|dsb)";
        String message = "wqnmlgb,你怎么这么的sb,你这个dsb";
        message = message.replaceAll(regex,"***");
        System.out.println(message);

    }

}
